package com.esri.core.tasks.geodatabase;

import com.esri.core.internal.tasks.PollingHelper;
import com.esri.core.internal.tasks.TaskListener;
import com.esri.core.internal.tasks.b.c;
import com.esri.core.internal.tasks.d;
import com.esri.core.io.UserCredentials;
import com.esri.core.map.CallbackListener;
import com.esri.core.tasks.geodatabase.GeodatabaseStatusInfo;

/* loaded from: classes.dex */
class RequestAndPollGeodatabaseTask extends d<GeodatabaseStatusInfo> {
    private static final long serialVersionUID = 1;
    private PollingHelper<GeodatabaseStatusInfo, GeodatabaseStatusInfo.Status> _pollingHelper;
    private TaskListener<GeodatabaseStatusInfo> _requestAcceptedListener;

    public RequestAndPollGeodatabaseTask(GenerateGeodatabaseParameters generateGeodatabaseParameters, String str, UserCredentials userCredentials) {
        super(generateGeodatabaseParameters, str, userCredentials);
        this._pollingHelper = new PollingHelper<>();
    }

    public RequestAndPollGeodatabaseTask(GenerateGeodatabaseParameters generateGeodatabaseParameters, String str, UserCredentials userCredentials, TaskListener<GeodatabaseStatusInfo> taskListener, TaskListener<GeodatabaseStatusInfo> taskListener2) {
        super(generateGeodatabaseParameters, str, userCredentials, taskListener2);
        this._pollingHelper = new PollingHelper<>();
        this._requestAcceptedListener = taskListener;
    }

    public void setStatusCallback(GeodatabaseStatusCallback geodatabaseStatusCallback, CallbackListener<?> callbackListener) {
        this._pollingHelper.a(geodatabaseStatusCallback, callbackListener);
    }

    @Override // com.esri.core.internal.tasks.a
    public GeodatabaseStatusInfo execute() throws Exception {
        UserCredentials credentials = getCredentials();
        String execute = new c((GenerateGeodatabaseParameters) getActionInput(), getServiceURL(), credentials).execute();
        TaskListener<GeodatabaseStatusInfo> taskListener = this._requestAcceptedListener;
        if (taskListener != null) {
            taskListener.onCompletion((short) 1, new GeodatabaseStatusInfo(getServiceURL(), execute));
        }
        GeodatabaseStatusInfo a = this._pollingHelper.a(1000L, execute, credentials, GeodatabaseStatusInfo.Status.PENDING, new GeodatabaseStatusPollHelper());
        a.setUpdateUrl(execute);
        return a;
    }
}
